package com.jamila.scancode.controller;

import com.jamila.scancode.entity.Contacts;
import com.jamila.scancode.entity.MainExperience;
import com.jamila.scancode.result.Result;
import com.jamila.scancode.service.MainExperienceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author JAMILA
 * @since 2024-03-30 01:42:05
 */
@Api(tags = "主要经历控制器")
@RestController
@RequestMapping("/mainExperience")
public class MainExperienceController {

    @Autowired
    private MainExperienceService mainExperienceService;

    @ApiOperation("保存主要经历信息")
    @PostMapping("save")
    public Result save(@RequestBody MainExperience mainExperience){
        //根据手机号判断是否已存在信息；若存在则执行更新操作；若不存在则执行保存操作
        boolean save = mainExperienceService.saveData(mainExperience);
        return save?Result.ok():Result.fail().message("保存主要经历信息失败");
    }

    @ApiOperation("根据手机号查询主要经历信息")
    @GetMapping("getMainExperience/{tel}")
    public Result getMainExperience(@PathVariable String tel){
        MainExperience mainExperience=mainExperienceService.getMainExperience(tel);
        return mainExperience!=null?Result.ok(mainExperience):Result.ok().message("获取主要经历信息失败");
    }

}
